/**
 * Copyright (C)  2011  chen wei hua.
 * Permission is granted to copy, distribute and/or modify this document
 * under the terms of the GNU Free Documentation License, Version 2.0
 * or any later version published by the Free Software Foundation;
 * with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
 * A copy of the license is included in the section entitled "GNU Free Documentation License".
 */
package com.javaeye.plan.dao;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.javaeye.plan.dto.MonthPlanDetail;

public class MonthPlanDAOHibernate extends HibernateDaoSupport implements MonthPlanDAO {
	
	@Override
	public void saveMonthPlan(MonthPlanDetail detail) {
		getHibernateTemplate().saveOrUpdate(detail);
	}
	
	public void deleteMonthPlan(int detailId) {
		Object o = getHibernateTemplate().load(MonthPlanDetail.class, detailId);
		getHibernateTemplate().delete(o);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<MonthPlanDetail> getPlanDetailInfo(String monthNo) {
		final String queryString = "from MonthPlanDetail d where d.monthNo=? order by d.productId";
		return (List<MonthPlanDetail>)getHibernateTemplate().find(queryString, monthNo);
	}
}
